GPIO_PATH := ../s3c2440/gpioctl
DELAY_PATH := ../s3c2440/DelayFuncWithoutTimer
GPIO_LIB := gpioctl
DELAY_LIB := delay

ifndef $(CROSS-BULID)
	CROSS-BULID = arm-linux-
endif

CC := ${CROSS-BULID}gcc
AR := ${CROSS-BULID}ar

CFLAGS := -Wall -Werror -O2
# inculde file path
CFLAGS += -I${GPIO_PATH} -I${DELAY_PATH}
# lib file
CFLAGS += -L${GPIO_PATH} -l${GPIO_LIB} -L${DELAY_PATH} -l${DELAY_LIB}

G2P_FILES = $(wildcard *.c)  
G2P_OBJ = $(G2P_FILES:.c=.o)
G2P_LIB =  gpio-i2c
G2P_TESTBIN = gpio-i2ctest


staticlib : $(G2P_OBJ)
	$(MAKE) -C $(GPIO_PATH) CROSS-BULID=$(CROSS-BULID) staticlib
	$(MAKE) -C $(DELAY_PATH) CROSS-BULID=$(CROSS-BULID) staticlib
	$(AR) rcs lib$(G2P_LIB).a $^

test : $(G2P_OBJ)
	$(MAKE) -C $(GPIO_PATH) staticlib CROSS-BULID=$(CROSS-BULID)
	$(MAKE) -C $(DELAY_PATH) staticlib CROSS-BULID=$(CROSS-BULID)
	${CC} -o $(G2P_TESTBIN) $^ ${CFLAGS}

clean:  
	$(RM) $(G2P_OBJ)